<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <title>登录页面</title>
    <link rel="stylesheet" href="/layui/css/layui.css">
    <link rel="stylesheet" href="/jquery/jquery.min.js">
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        html {
            height: 100%;
        }

        body {
            height: 100%;
            background: #fff url(/images/background.png) 50% 50% no-repeat;
            background-size: cover;
        }

        .dowebok {
            position: absolute;
            left: 70%;
            top: 50%;
            width: 430px;
            height: 550px;
            margin: -300px 0 0 -215px;
            border: 1px solid #fff;
            border-radius: 20px;
            overflow: hidden;
        }

        .logo {
            width: 104px;
            height: 104px;
            margin: 50px auto 80px;
            background: url(/images/login.png) 0 0 no-repeat;
        }

        .form-item {
            position: relative;
            width: 360px;
            margin: 0 auto;
            padding-bottom: 30px;
        }

        .form-item input {
            width: 288px;
            height: 48px;
            padding-left: 70px;
            border: 1px solid #fff;
            border-radius: 25px;
            font-size: 18px;
            color: #fff;
            background-color: transparent;
            outline: none;
        }

        .form-item button {
            width: 360px;
            height: 50px;
            border: 0;
            border-radius: 25px;
            font-size: 18px;
            color: #1f6f4a;
            outline: none;
            cursor: pointer;
            background-color: #fff;
        }

        #username {
            background: url(/images/emil.png) 20px 14px no-repeat;
        }

        #password {
            background: url(/images/password.png) 23px 11px no-repeat;
        }

        .tip {
            display: none;
            position: absolute;
            left: 20px;
            top: 52px;
            font-size: 14px;
            color: #f50;
        }

        .reg-bar {
            width: 360px;
            margin: 20px auto 0;
            font-size: 14px;
            overflow: hidden;
        }

        .reg-bar a {
            color: #fff;
            text-decoration: none;
        }

        .reg-bar a:hover {
            text-decoration: underline;
        }

        .reg-bar .reg {
            float: left;
        }

        .reg-bar .forget {
            float: right;
        }

        .dowebok ::-webkit-input-placeholder {
            font-size: 18px;
            line-height: 1.4;
            color: #fff;
        }

        .dowebok :-moz-placeholder {
            font-size: 18px;
            line-height: 1.4;
            color: #fff;
        }

        .dowebok ::-moz-placeholder {
            font-size: 18px;
            line-height: 1.4;
            color: #fff;
        }

        .dowebok :-ms-input-placeholder {
            font-size: 18px;
            line-height: 1.4;
            color: #fff;
        }

        @media screen and (max-width: 500px) {
            * {
                box-sizing: border-box;
            }
        }

        .type {
            text-align: center;
            font-size: 18px;
            color: white;
            padding-bottom: 10px;
        }

        .stype {
            margin-top: 6px;
            margin-right: 30px;
        }
    </style>
</head>

<body>
    <div class="dowebok">
        <div class="logo"></div>
        <div class="form-item">
            <input id="username" type="text" autocomplete="off" placeholder="账号">
            <p class="tip">请输入正确的账号</p>
        </div>
        <div class="form-item">
            <input id="password" type="password" autocomplete="off" placeholder="登录密码">
            <p class="tip">账号或密码不正确</p>
        </div>
        <div>
            <div class="type">
                <div class="layui-form-item">
                    <label class="layui-form-label" style="padding-left: 40px;">所属医院:</label>
                    <div class="layui-input-block">
                        <select class="stype" name="dp" id="dp" lay-verify="required" lay-filter="xmFilter">
                            <option value="">请选择所属医院</option>
                        </select>
                    </div>
                </div>
            </div>

        </div>
        <div class="form-item"><button id="submit">登 录</button></div>

    </div>

    </div>
    <script src="/jquery/jquery.min.js"></script>
    <script type="text/javascript" src="/layui/layui.js"></script>
    <script>
        $(function () {
            $('input').val('')
            $('#submit').on('click', function () {
                $('.tip').show()
            })
        })
        layui.use(['form', 'upload', 'layer'], function () {
            var form = layui.form;
            $.ajax({
                url: 'http://localhost:8080/hospitals/getHosName',
                dataType: 'json',
                type: 'get',

                success: function (data) {
                    console.log(data),
                        $.each(data.data, function (index, value) {
                            $('#dp').append(new Option(value.hospitalName));
                        });
                    layui.form.render("select");
                }
            })
        })
        $("#submit").click(function () {
            var hospitalId = $("#username").val();
            var hospitalPassword = $("#password").val();
            var hospitalName = $("#dp option:selected").val();



            $.ajax({
                url: 'http://localhost:8080/hospitals/login',
                type: 'POST',
                dataType: 'JSON',
                data: {
                    hospitalId: hospitalId,
                    hospitalPassword: hospitalPassword,
                    hospitalName: hospitalName,
                },

                success: function (obj) {
                    if (obj.code != 0) {
                        alert(obj.msg);
                    } else {
                        window.localStorage.setItem("token", obj.msg);
                        window.localStorage.setItem("Hospital", JSON.stringify(obj.obj));
                        window.location.href = "homePage.html";
                    }
                }
            })
            return false;

        }
        )
    </script>

    <div style="text-align:center;">

    </div>

</body>

</html>